//
//  HHContractDetailReformer.m
//  HHBroker
//
//  Created by He Wei on 9/27/15.
//  Copyright © 2015 harry. All rights reserved.
//

#import "HHContractDetailReformer.h"

@implementation HHContractDetailReformer
+ (NSArray *)reformDataWithRespone:(id)response
{
    NSArray *titleArray = @[@{@"key": @"percentage", @"title": @"佣金比例"},
                            @{@"key": @"servicetype", @"title": @"签单金额"},
                            @{@"key": @"con_id", @"title": @"合同id"},
                            @{@"key": @"true_name", @"title": @"客户姓名"}];
    /*
     *   NSString *con_id;         // 合同id
     *   NSString *percentage;     // 佣金比例
     *   NSString *amt;            // 佣金收入
     *   NSString *servicetype;    // 签单金额
     *   NSString *true_name;      // 客户姓名
     *   NSString *infosend;       // 1为经纪人自己跟单, 0否
     *
     *
     */
    if (!titleArray || titleArray.count == 0 || !response) {
        return [[NSArray alloc] init];
    }
    NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:10];
    for (NSDictionary *dic in titleArray) {
        NSString *title = [dic objectForKey:@"title"];
        NSString *key = [dic objectForKey:@"key"];
        NSString *value = [response objectForKey:key];
        if ([value isKindOfClass:[NSNull class]]) {
            continue;
        }
        if (title && value) {
            value = [NSString stringWithFormat:@"%@", value];
            NSDictionary *moneyDetail = @{@"title":title, @"value":value};
            [array addObject:moneyDetail];
        }
    }
    return array;
}
@end
